import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import './assets/global.css'
//引入路由
import router from './router'
import axios from 'axios'
//使用路由
const app = createApp(App)
import zhCn from 'element-plus/es/locale/lang/zh-cn'

//为axios配置请求根路径
// axios.defaults.baseURL=""
//挂载到全局属性中 方便调用
app.config.globalProperties.$http = axios
//挂载路由
app.use(router)
//挂载饿了么
app.use(ElementPlus, { locale: zhCn })

app.mount('#app')

//解决缩放报错问题
const debounce = (fn, delay) => {
    let timer;
    return (...args) => {
        if (timer) {
            clearTimeout(timer);
        }
        timer = setTimeout(() => {
            fn(...args);
        }, delay);
    };
};

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
        callback = debounce(callback, 200);
        super(callback);
    }
};